package com.linkstec.bookshop.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * 
 * @ClassName:  PropertiesUtil  获取配置文件中值的工具类
 * @Description:TODO   
 * @author:  JGQiang
 * @date:   2018年11月13日 下午3:27:39
 */
public class PropertiesUtil {

	public static String getValue(String keyName){
		String value = "";
		Properties p = new Properties();
		try {
			//读取jdbc.properties文件,使用InputStreamReader字符流防止文件中出现中文导致乱码
			p.load(new InputStreamReader(new FileInputStream(PropertiesUtil.class.getResource("/").getPath()+"db.properties"),"UTF-8"));
			value = p.getProperty(keyName,"获取失败");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return value;
	}
}
